//
//  ConcatViewController.swift
//  testRxSwift
//
//  Created by 火星人 on 2017/7/25.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit
import RxSwift

class ConcatViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addTapWithHandle { (tap) in
            
            let disposeBag = DisposeBag()
            let subject1 = PublishSubject<String>()
            let subject2 = PublishSubject<String>()
            let variable = Variable(subject1)
            variable.asObservable()
                .concat()
                .subscribe { print($0) }
                .disposed(by: disposeBag)
            subject1.onNext("11")
            subject1.onNext("12")
            
            variable.value = subject2
            subject2.onNext("I would be ignored")
            
            subject1.onCompleted()

            subject2.onNext("21")
            subject2.onNext("22")
        }
        

    }
}
